//
//  JGAboutMeController.m
//  JGRider
//
//  Created by 单启志 on 2018/1/30.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGAboutMeController.h"
#import "JGAboutMeCell.h"
#import "JGAboutMeHeadView.h"
#import "JGAboutMeModel.h"
@interface JGAboutMeController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray<JGAboutMeModel*>*datas;
@end

@implementation JGAboutMeController
static NSString *cellId=@"aboutMeCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    [self configSubViews];
}

-(void)configSubViews{
    self.title=@"关于我们";
    self.datas=[JGAboutMeModel models];
    [self.view addSubview:self.tableView];
}

#pragma mark - tableview delegate

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    JGAboutMeHeadView *headView=[[[NSBundle mainBundle]loadNibNamed:@"JGAboutMeHeadView" owner:nil options:nil]lastObject];

    return headView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return AdaptedHeight(148);
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.datas.count;
    //return self.datas.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==3) {
        return AdaptedWidth(53);
    }
    return AdaptedHeight(50);

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    JGAboutMeCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
    cell.model=self.datas[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    JGAboutMeModel *model=self.datas[indexPath.row];
    if(model.isCanPush){
        JGpushViewController([[model.pushClass alloc]init]);
    }

}

#pragma mark - getter setter
-(UITableView *)tableView{

    if (!_tableView) {

        _tableView =[[UITableView alloc]initWithFrame:CGRectMake(0,self.lmj_navgationBar.height, JGScreenW, JGScreenH-self.lmj_navgationBar.height) style:UITableViewStyleGrouped];
        _tableView.backgroundColor=[UIColor whiteColor];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([JGAboutMeCell class]) bundle:nil] forCellReuseIdentifier:cellId];

        _tableView.showsVerticalScrollIndicator=NO; _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        _tableView.delegate=self;
        _tableView.dataSource=self;
    }

    return _tableView;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}




@end
